﻿package com.cf.core.view{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.events.*;
	public class Button extends Sprite {
		private var btn:Sprite = new Sprite();
		private var textLabel:TextField;
		public function Button() {
			addLabel();
			btn.addEventListener(MouseEvent.MOUSE_OVER, handleOver);
			btn.addEventListener(MouseEvent.MOUSE_OUT, handleOut);
			addChild(btn);
		}//fn
		private function addLabel():void {
			textLabel= new TextField()
			textLabel.text = "No Value";
			textLabel.x = 5;
			textLabel.y = 2;
			textLabel.wordWrap=false;
			textLabel.selectable = false;
			btn.addChild(textLabel);
			drawButton();
		}//fn
		private function drawButton():void{
			btn.graphics.clear();
			btn.graphics.beginFill(0xD4D4D4); // grey color
			btn.graphics.drawRoundRect(0, 0, textLabel.width+10, textLabel.height+5, 10, 10); // x, y, width, height, ellipseW, ellipseH
			btn.graphics.endFill();
		}//fn
		public function set value(s:String):void{
			textLabel.text = s;
			textLabel.width = textLabel.textWidth+5;
			textLabel.height = textLabel.textHeight+2;
			drawButton();
		}//fn
		private function handleOver(event:MouseEvent):void {
			btn.x += 0.5;
			btn.y += 0.2;
		}//fn
		private function handleOut(event:MouseEvent):void {
			btn.x -= 0.5;
			btn.y -= 0.2;
		}//fn
	}//class
}//package